#DEFINE vpCrLf CHR(13)+CHR(10)
#DEFINE vpUnicode 5
DECLARE INTEGER CreateDirectory IN kernel32;
		STRING lpPathName, STRING @lpSecurityAttr
		
#DEFINE IMAGE_BITMAP 0
#DEFINE LR_LOADFROMFILE 16
DECLARE INTEGER LoadImage IN user32;
		INTEGER hinst, STRING lpszName, INTEGER uType, ;
		INTEGER cxDesired, INTEGER cyDesired, INTEGER fuLoad
DECLARE INTEGER DeleteObject IN Gdi32;
		INTEGER ho
szSavePath = "C:\Argox"
szSaveFile = "C:\Argox\PPLZ_Example.Prn"
sznop1     = "nop_front" + vpCrLf
sznop2     = "nop_middle" + vpCrLf
DECLARE integer Z_Bar2d_Maxi in WINPPLZ.DLL integer x, integer y, integer nMode, integer nSymbol, ;
		integer nTotal, integer nClass, integer nCountry, string cZipCode1, string cZipCode2, ;
		string data_Renamed, integer increase
DECLARE integer Z_Bar2d_PDF417 in WINPPLZ.DLL integer x, integer y, integer o, integer h, integer s, ;
		integer c, integer r, integer t, integer narrow, string data_Renamed, integer increase
DECLARE integer Z_Bar2d_DataMatrix in WINPPLZ.DLL integer x, integer y, integer o, integer h, ;
		integer c, integer r, string data_Renamed, integer increase
DECLARE Z_ClosePrn in WINPPLZ.DLL
DECLARE integer Z_CreatePrn in WINPPLZ.DLL integer selection_Renamed, string filename
DECLARE integer Z_Set_FlashMemory in WINPPLZ.DLL integer Status_Renamed
DECLARE Z_Set_Format_New in WINPPLZ.DLL string FormatName
DECLARE integer Z_Del_Format in WINPPLZ.DLL integer memory_Renamed, string formatname
DECLARE integer Z_Del_Graphic in WINPPLZ.DLL integer memory_Renamed, string graphicname
DECLARE integer Z_Draw_Box in WINPPLZ.DLL integer x, integer y, integer width_Renamed, ;
		integer height_Renamed, integer thickness
DECLARE integer Z_Draw_Line in WINPPLZ.DLL integer x, integer y, integer width_Renamed, ;
		integer height_Renamed
DECLARE  string Z_Get_DLL_Version in WINPPLZ.DLL integer nShowMessage
DECLARE integer Z_Get_DLL_VersionA in WINPPLZ.DLL integer nShowMessage
DECLARE integer Z_Get_Graphic_ColorBMP in WINPPLZ.DLL integer x, integer y, integer mem_mode, ;
		string filename
DECLARE integer Z_Get_Graphic_ColorBMPEx in WINPPLZ.DLL integer x, integer y, integer nWidth, integer nHeight, ;
		integer rotate, integer mem_mode, string id_name, string filename
DECLARE integer Z_Get_Graphic_ColorBMP_HBitmap in WINPPLZ.DLL integer x, integer y, integer nWidth, integer nHeight, ;
		integer rotate, integer mem_mode, string id_name, integer hbm
DECLARE integer Z_Initial_Setting in WINPPLZ.DLL integer Type_Renamed, string Source
DECLARE integer Z_WriteData in WINPPLZ.DLL integer IsImmediate, string pbuf, integer length
DECLARE integer Z_ReadData in WINPPLZ.DLL string @pbuf, integer length, integer dwTimeoutms
DECLARE integer Z_Load_Graphic in WINPPLZ.DLL integer x, integer y, integer memory_Renamed, ;
		string graphic_name, integer horizontal, integer vertical
DECLARE integer Z_Open_ChineseFont in WINPPLZ.DLL string path_Renamed
DECLARE integer Z_Print_Form in WINPPLZ.DLL integer copies, integer labset, integer mem_mode, ;
		string form_out
DECLARE integer Z_Print_Out in WINPPLZ.DLL integer sets, integer copies
DECLARE integer Z_Prn_Barcode in WINPPLZ.DLL integer x, integer y, integer ori, integer narrow, ;
		integer width_Renamed, integer height_Renamed, short type_Renamed, integer increase, ;
		string data_Renamed, short human1, short human2, short human3, short human4, short human5
DECLARE integer Z_Prn_Text in WINPPLZ.DLL integer x, integer y, integer ori, short font_Renamed, ;
		integer height_Renamed, integer width_Renamed, integer numeric, string data_Renamed
DECLARE integer Z_Prn_Text_Chinese in WINPPLZ.DLL integer x, integer y, integer fonttype, ;
		string id_name, string data_Renamed, integer mem_mode
DECLARE integer Z_Prn_Text_TrueType in WINPPLZ.DLL integer x, integer y, integer FSize_Renamed, ;
		string FType, integer Fspin, integer FWeight, integer FItalic, integer FUnline, ;
		integer FStrikeOut, string id_name, string data_Renamed, integer mem_mode
DECLARE integer Z_Prn_Text_TrueType_W in WINPPLZ.DLL integer x, integer y, integer FHeight, ;
		integer FWidth, string FType, integer Fspin, integer FWeight, integer FItalic, ;
		integer FUnline, integer FStrikeOut, string id_name, string data_Renamed, integer mem_mode
DECLARE Z_Clear_Memory in WINPPLZ.DLL
DECLARE Z_Clear_MemoryEx in WINPPLZ.DLL integer nMode
DECLARE integer Z_Set_Backfeed in WINPPLZ.DLL integer nDistance
DECLARE integer Z_Set_Darkness in WINPPLZ.DLL integer darkness
DECLARE integer Z_Set_DebugDialog in WINPPLZ.DLL integer nEnable
DECLARE integer Z_Set_Label in WINPPLZ.DLL integer Length
DECLARE integer Z_Set_Mode in WINPPLZ.DLL short mode
DECLARE integer Z_Set_Origin in WINPPLZ.DLL integer y
DECLARE integer Z_Set_Paper in WINPPLZ.DLL short mode
DECLARE integer Z_Set_Prncomport in WINPPLZ.DLL integer baud, integer parity, integer data_Renamed, ;
		integer stop
DECLARE integer Z_Set_Prncomport_PC in WINPPLZ.DLL integer nBaudRate, integer nByteSize, ;
		integer nParity, integer nStopBits, integer nDsr, integer nCts, integer nXonXoff
DECLARE Z_Set_Reset in WINPPLZ.DLL
DECLARE integer Z_Set_Speed in WINPPLZ.DLL integer print_Renamed
DECLARE integer Z_Set_TPH in WINPPLZ.DLL short mode
DECLARE integer Z_Set_Unit in WINPPLZ.DLL short Unit
DECLARE integer Z_Set_Gap in WINPPLZ.DLL integer nPatern, integer nGap
DECLARE integer Z_Set_ProcessDlg in WINPPLZ.DLL integer nShow
DECLARE integer Z_Set_ErrorDlg in WINPPLZ.DLL integer nShow
DECLARE integer Z_Bar2d_QRCode in WINPPLZ.DLL integer x, integer y, integer nModel, integer nMagni, ;
		integer nErr_Cor, integer nInput, string data_Renamed, integer increase
DECLARE integer Z_Set_PrintWidth in WINPPLZ.DLL integer nDotwidth
DECLARE integer Z_Print_OutQuality in WINPPLZ.DLL integer nTotal, integer sets, integer copies, ;
		integer nPause
DECLARE integer Z_GetUSBBufferLen in WINPPLZ.DLL
DECLARE integer Z_EnumUSB in WINPPLZ.DLL string @buf
DECLARE integer Z_CreateUSBPort in WINPPLZ.DLL integer nPort
DECLARE integer Z_CreatePort in WINPPLZ.DLL integer nPortType, integer nPort, string filename
DECLARE integer Z_Set_Mirror in WINPPLZ.DLL short direction
DECLARE integer Z_Bar2d_RSS in WINPPLZ.DLL integer x, integer y, short ori, integer rtype, ;
		integer mag, integer height_Renamed, integer seg, string data1, string data2
DECLARE integer Z_GetNetPrinterBufferLen in WINPPLZ.DLL
DECLARE integer Z_EnumNetPrinter in WINPPLZ.DLL string @buf
DECLARE integer Z_CreateNetPort in WINPPLZ.DLL integer nPort
DECLARE integer Z_Prn_Text_TrueType_Uni in WINPPLZ.DLL integer x, integer y, integer FSize_Renamed, ;
		string FType, integer Fspin, integer FWeight, integer FItalic, integer FUnline, ;
		integer FStrikeOut, string id_name, string data_Renamed, integer format_Renamed, ;
		integer mem_mode
DECLARE integer Z_Prn_Text_TrueType_UniB in WINPPLZ.DLL integer x, integer y, integer FSize_Renamed, ;
		string FType, integer Fspin, integer FWeight, integer FItalic, integer FUnline, ;
		integer FStrikeOut, string id_name, string data_Renamed, integer format_Renamed, ;
		integer mem_mode
DECLARE integer Z_GetUSBDeviceInfo in WINPPLZ.DLL integer nPort, string @pDeviceName, ;
		integer @pDeviceNameLen, string @pDevicePath, integer @pDevicePathLen
DECLARE integer Z_Set_EncryptionKey in WINPPLZ.DLL string encryptionKey
DECLARE integer Z_Check_EncryptionKey in WINPPLZ.DLL string decodeKey, string encryptionKey, ;
		integer dwTimeoutms
DECLARE integer Z_Set_CommTimeout in WINPPLZ.DLL integer ReadTotalTimeoutConstant, ;
		integer WriteTotalTimeoutConstant
DECLARE integer Z_Get_CommTimeout in WINPPLZ.DLL integer @pReadTotalTimeoutConstant, ;
		integer @pWriteTotalTimeoutConstant
DECLARE integer Z_Set_LabelForSmartPrint in WINPPLZ.DLL integer lablength, ;
		integer gaplength		
		
MessageBox("Print Label", "PPLZ Lib Example")
&& Test code start
&& open port.
PRIVATE nLen, ret, sw
PRIVATE pbuf, ver, strmsg
pbuf = Space(128)

&& dll version.
ver = Z_Get_DLL_Version(0)

&& search port.
nLen = Z_GetUSBBufferLen() + 1
strmsg = "DLL " + ver + vpCrLf   && only sample coding, not smart.
If nLen > 1
    PRIVATE buf1, buf2
    PRIVATE len1, len2
    len1 = 128
    len2 = 128
    buf1 = Space(len1)
    buf2 = Space(len2)
    Z_EnumUSB(@pbuf)
    Z_GetUSBDeviceInfo(1, @buf1, @len1, @buf2, @len2)
    sw = 1
    If 1 == sw
       ret = Z_CreatePrn(12, buf2)   && open usb.
    Else
       ret = Z_CreateUSBPort(1)   && must call Z_GetUSBBufferLen() function fisrt.
    EndIf
    If 0 < ret
        strmsg = strmsg + "Open USB fail!"
    Else
        strmsg = strmsg + "Open USB:" + vpCrLf + "Device name: "
        strmsg = strmsg + Left(buf1, len1)
        strmsg = strmsg + vpCrLf + "Device path: "
        strmsg = strmsg + Left(buf2, len2)
        && sw = 2
        If 2 == sw
          && get host status.
          pbuf = "~HS\r\n"
          Z_WriteData(1, pbuf, 5)   && ~HS
          ret = Z_ReadData(@pbuf, 82, 1000)
        EndIf
    EndIf
Else
    CreateDirectory(szSavePath, null)
    ret = Z_CreatePrn(0, szSaveFile)   && open file.
    strmsg = strmsg + "Open " + szSaveFile
    If 0 < ret
        strmsg = strmsg + " file fail!"
    Else
        strmsg = strmsg + " file succeed!"
    EndIf
EndIf
MessageBox(strmsg)
If 0 < ret
    Return
EndIf

&& sample setting.
Z_Set_DebugDialog(1)
Z_Set_Origin(0)
Z_Set_Paper(ASC("Y"))
Z_Set_TPH(ASC("D"))
Z_Set_Unit(ASC("D"))   && dot.
Z_Set_Darkness(8)
Z_Set_Label(203 * 3)
Z_Set_PrintWidth(203 * 4)
Z_Clear_Memory()   && clear memory.
Z_WriteData(0, sznop2, Len(sznop2))
Z_WriteData(1, sznop1, Len(sznop1))
&& When using standard label, and the printer is Intelli Print mode or Smart Print mode,
&& When calling this function and giving the correct label information,
&& the immediate print function will be enabled according to the label length setting.
Z_Set_LabelForSmartPrint(254 * 3, 30)  && abel information: length= 3 * 25.4 mm, gap= 3 mm.

&& draw box.
Z_Draw_Box(20, 20, 760, 560, 4)
Z_Draw_Line(400, 20, 4, 560)

&& print text, true type text.
Z_Prn_Text(30, 40, 1, ASC("D"), 1, 1, 0, "PPLZ Lib Example")
Z_Prn_Text_TrueType(30, 100, 30, "Arial", 1, 400, 0, 0, 0, "AA", "TrueType Font", 0)   && save in printer.
Z_Prn_Text_TrueType_W(30, 160, 20, 20, "Times New Roman", 1, 400, 0, 0, 0, "AB", "TT_W: 多字元測試", 0)

PRIVATE buff1
buff1 = STRCONV("TT_Uni: 多字元測試", vpUnicode)   && Converts double-byte characters to UNICODE(wide characters).
buff1 = buff1 + CHR(0) + CHR(0)   && null.
Z_Prn_Text_TrueType_Uni(30, 220, 30, "Times New Roman", 1, 400, 0, 0, 0, "AC", buff1, 1, 0)   && UTF-16

buff1 = CHR(255) + CHR(254)   && UTF-16.
buff1 = buff1 + STRCONV("TT_UniB: 多字元測試", vpUnicode)   && Converts double-byte characters to UNICODE(wide characters).
buff1 = buff1 + CHR(0) + CHR(0)   && null.
Z_Prn_Text_TrueType_UniB(30, 280, 30, "Times New Roman", 1, 400, 0, 0, 0, "AD", buff1, 0, 0)   && Byte Order Mark.

&& barcode.
Z_Prn_Barcode(420, 100, 1, 2, 3, 40, ASC("3"), 1, "1234", ASC("N"), ASC("Y"), ASC("N"), ASC("N"), ASC("N"))   && have a counter.
Z_Bar2d_QRCode(420, 190, 2, 3, 3, 1, "QR CODE", 0)

&& picture.
Z_Get_Graphic_ColorBMP(420, 280, 0, "bb.bmp")   && Color bmp file to ram.
Z_Get_Graphic_ColorBMPEx(420, 330, 200, 150, 2, 0, "bb1", "bb.bmp")   && 180 angle
PRIVATE himage
himage = LoadImage(0,"bb.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE)
Z_Get_Graphic_ColorBMP_HBitmap(630, 280, 250, 80, 1, 0, "bb2", himage)   && 90 angle.
If 0 != himage
	DeleteObject(himage)
EndIf

&& output.
Z_Print_Out(2, 1)   && copy 2.

&& close port.
Z_ClosePrn()

clear dlls